<!DOCTYPE html>
<html lang="en"><!-- InstanceBegin template="/Templates/MainTemplate.dwt" codeOutsideHTMLIsLocked="false" -->
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
<!-- #BeginEditable "doctitle" -->
<title>how to easily develop a non-blocking concurrent application ?</title>  
<!-- #EndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
    <!-- Bootstrap core CSS -->
     <link rel="stylesheet" href="css/bootstrap.min.css">   

    <!-- Custom styles for this template -->
    <link href="css/starter-template.css" rel="stylesheet">

   <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->    
  </head>
<body>
 <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="index.html">Jdon Framework</a>
        </div>
        <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
                <li class="active"><a href="index.html">Home</a></li>
               <li><a href="https://sourceforge.net/projects/jdon/files/">Download</a></li>
               <li><a href="doc.htm" >Document</a></li>
               <li><a href="quickconf.html">Qucik Start</a> </li>
               <li><a href="examples.html">Examples</a></li>
               <li ><a href="https://github.com/banq/jdonframework">Github</a></li>
               <li><a href="articles.html">Articles</a></li>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </div>
    

    <div class="container">
     <div class="starter-template">     
    
 <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">  
  <tr>     
    <td bgcolor="#FFFFFF"  valign="top" align="left">

                  
				<!-- #BeginEditable "main" -->
				<h1>how to easily develop a non-blocking concurrent application ? </h1>
				<p>Most programmers are good at a synchronous mode that be executed sequentially in a thread, In a blocking system, wait thread is idle but continue to consume system resources.<br>
				  </p>
				<p>here is a formula for high transaction volume: </p>
				<p><br>
				  the number of idle threads =(arrival_rate * processing_time)<br>
				  the result can be a very big number if the arrival_rate is high.</p>
				<p>Blocking system is running under a very ineffective mode. No high throughout, no high CPU load.blocking is not fit for multi-core CPU, and it is cancer that will kill the system later.</p>
				<p>when we read data from socket by this way:<br>
				  While(true){<br>
				  ...<br>
				  }</p>
				<p><br>
				  this will cost CPU and block the system, there are many blocking in JDK, such as java.concurrent.BlockingQueue LinkedBlockingQueue, they are belong to false concurrent.</p>
				<p>To avoid synchronous  lock and blocking, we need use &quot;volatile&quot;  or &quot;Visibility&quot;  and &quot;immutable&quot;, they are maybe difficult for most programmers.</p>
				<p>A good way for non-blocking concurrent is queue of no lock, not JDK's BlockingQueue , the RingBuffer of Disruptor is a no-lock queue that can be shared between two threads. Actors mode is another non-blocking concurrent , it  shares nothing. </p>
				<p>In a  non-blocking concurrent system: make a call which returns a result.  don't need to use the result until at a much later stage of your process. don't need to wait immediately after making the call, instead you can proceed to do other things until you reach the point where you need to use the result. the call itself will return a &quot;future&quot; handle immediately. The caller can go off doing other things and later poll the &quot;future&quot; handle to see if the response if ready. </p>
				<p>We can use Domain Events wrapping the RingBuffer of Disruptor, so threads communicates through events or messages, so no shared state, nothing to synchronize.this is  Message-Passing Concurrency. </p>
				<p>we design Message-Passing Concurrency into open source jdon framework.</p>
				<p>the  non-blocking concurrent way of jdon framework is here: Domain Model sends events to  another thread(a consumer) by RingBuffer in Disruptor, so two threads can communicates through event ;After the consumer done, it will put the result in another RingBuffer that publisher can read or blocking read it, decided by business is or not executed sequentially.</p>
				<p>by domain events and DCI in  jdon framework we make  an exploratory to promote non-blocking concurrent programming paradigm. jdon framework can help most programmers quietly going to the way of non-blocking concurrent programming when they thinking in DDD.</p>
				<p>DCI and Domain Events are different abstract high levels based concurrent programming,  DCI is easier to be understand than Domain Events , DCI and UML colors analysis method can successfully docking, it is the highest level of abstraction of business-oriented.</p>
				<p>here shows how to use DCI and Domain Events in jdon framework :</p>
				<p>&nbsp;</p>
				<p>If we already hold on a model object, we can implements various functions by its domain events,such as modify/update a model.Otherwise:We create a context, and there we inject events or functions into a new model object by RoleAssigner,such as create or delete a model.</p>
				<p>details in : </p>
				<p><strong><a href="DomainEvents.html">DDD</a></strong> <a href="DomainEvents.html"><strong>DCI</strong> and <strong>Domain</strong> <strong>Events</strong> <strong>example</strong></a><br>
				  </p> 
                  <p>　　</p>
                  <p>&nbsp;</p>
                   <!-- #EndEditable -->
                 
			  	
          </td>
		  <td width="340" valign="top"  bgcolor="#FFFFD7"> 
          <div class="adsensf" id="vgad336x280">
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 页上左336 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:336px;height:280px"
     data-ad-client="ca-pub-7573657117119544"
     data-ad-slot="6751585519"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- 页上左336 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:336px;height:280px"
     data-ad-client="ca-pub-7573657117119544"
     data-ad-slot="6751585519"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>         
 </td>
  </tr>
</table>


<table width="100%" border="0" cellspacing="0" cellpadding="0" height="2" bgcolor="#000000"  align="center">
              <tr>
                <td></td>
              </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td height="20" bgcolor="#CAC9BB" align="center">
  
  </td>
</tr>
</table>
 </div>
</div><!-- /.container -->

<!-- InstanceBeginEditable name="EditRegion3" --><!-- InstanceEndEditable -->
        <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
		<script src="js/bootstrap.min.js"></script>
<!-- AddThis Smart Layers BEGIN -->
<!-- Go to http://www.addthis.com/get/smart-layers to customize -->
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-52c4b79515624135"></script>
<script type="text/javascript">
  addthis.layers({
    'theme' : 'transparent',
    'share' : {
      'position' : 'left',
      'numPreferredServices' : 5
    },  
    'whatsnext' : {},  
    'recommended' : {} 
  });
</script>
<!-- AddThis Smart Layers END -->    
</body>
<!-- InstanceEnd --></html>
